<?php

namespace App\Traits;

use App\Services\Admin\AuthService;

trait PermissionTrait
{
    /**
     * 检查用户是否有指定权限
     * @param int $adminId 管理员ID
     * @param string|array $permission 权限标识
     * @return bool
     */
    protected function checkPermission(int $adminId, $permission): bool
    {
        $authService = app(AuthService::class);
        $permissions = $authService->getUserPermissions($adminId);
        return in_array($permission, $permissions);
    }
}
